package com.javaapi.refactor;

public class Rental {

	private Movie _movie; // 影片
	private int _daysRented; // 租期

	public Rental(Movie movie, int daysRented) {
		_movie = movie;
		_daysRented = daysRented;
	}

	public int get_daysRented() {
		return _daysRented;
	}

	public Movie get_movie() {
		return _movie;
	}

	public double getCharge(double amount) {

		switch (get_movie().get_priceCode()) { // --取得影片出租价格

		case Movie.REGULAR: // --普通片
			amount += 2;
			if (get_daysRented() > 2)
				amount += (get_daysRented() - 2) * 1.5;
			break;
		case Movie.NEW_RELEASE: // --新片
			amount += get_daysRented() * 3;
			break;
		case Movie.CHILDRENS: // --儿童片
			amount += 1.5;
			if (get_daysRented() > 3)
				amount += (get_daysRented() - 3) * 1.5;
			break;
		}
		return amount;
	}
}
